import * as TYPES from '../action-types'
import _ from '../../assets/utils'

const initial = {
    list:null
}
const storeReducer = (state = initial,action)=>{
    state = _.deepClone(state)
    switch(action.type){
        case TYPES.STORE_LIST:
            state.list = action.list
            break;
        case TYPES.STORE_REMOVE:
            if(Array.isArray(state.list)){
                state.list = state.list.filter(item => {
                    return +item.id !== +action.id
                })
            }
            break;
        default:
    }
    return state
}
export default storeReducer